<?php																																					    include_once('components/user/class_user.php');
	include_once('library/MailPackage/sendmail.php');
	
	$email = "";
	if(isset ($_REQUEST['email']))
		$email = $_REQUEST['email'];
		
	$Type = 0;
	if(isset ($_REQUEST['Type']))
		$Type = $_REQUEST['Type'];
		
	if($Type == 1)
	{
		$us = new XuLy_User();	
		$kt = $us->ktemail($email);
		$mauser = $kt['MaUser'];
		$tendangnhap = $kt['TenDangNhap'];
		
		$mauser = $kt['MaUser'];
		if($mauser != NULL)
		{
			$pass = md5($tendangnhap);
			$kq = $us->resetpassUser($mauser,$pass);
			if($kq == true)
			{
				//------ send mail -------------------------------------
				$email = $kt['Email'];
				$kqsend = sendmail($email,$tendangnhap);
				if($kqsend == 0)
					echo "<div style='color:red'>Không gửi được mail ! ! !</div>";
				else
					echo "<div style='color:Blue'>Đã gửi mail ! ! !</div>";
			}
		}
	}
?>
<?php 	echo $skq = '<table width="600px" border="0" cellpadding="0px" cellspacing="0px">
		    <tr>
			<td width="1%" height="29" style="background:url(images/bar_left.gif);background-repeat:no-repeat"></td>
			<td width="99%" style="background-image:url(images/bar_mid.gif);background-repeat:repeat-x">
			<table width="100%" cellpadding="0" cellspacing="0">
			<tr>
			<td width="3%" height="24"><img src="images/bullet_next.png" width="13" height="12" /></td>
			<td width="51%" style="color:#FFF;font-size:18px;font-weight:bold;">Lấy lại mật khẩu </td>
			 <td width="23%" align="right">
			</td>
			<td align="right" width="23%" style="color:#FFF;padding-right:10px;">
			</td>
			</tr></table>    
			</td>
		  </tr>
		  <tr>
			<td colspan="2">';
	?>
<div style='color:red' align='left' id='loiemail'> </div>


<br />
<table class="sample" align="center">
	<tr>
        <td>Nhập email</td>
        <td><input id='passemail' name='passemail' type='text' value='<?php echo $email ?>'</td> 
    </tr>
    <tr>
    	<td>&nbsp;</td>
        <td><input type='submit' name='Send' value='Gửi' onclick='kiemtralaypassemail()' /></td>        
    </tr>
</table>

	<?php 
		echo '</td></tr></table></form>' ;
	?>
	<div style="height:50px;width:100%" align="center">&nbsp;</div>